<template>
  <div class="preview-body">
    <div class="preview-body-bg"></div>
    <div class="preview-body-head">
      <div class="preview-body-head-title">{{ title }}</div>
    </div>
    <div class="preview-body-html" :style="htmlStyles" v-html="modelValue">
        
    </div>
  </div>
</template>

<script lang="ts" name="phone-preview" setup>
import { getCurrentInstance, computed, StyleValue } from "vue";


const { proxy:{$utils} } = getCurrentInstance() as any;

const props = withDefaults(
  defineProps<{
    title?: string | boolean;
    modelValue?: string;
  }>(),
  {
    title: "商品详细",
    modelValue: "",
  }
);
const htmlStyles = computed<StyleValue>(() => {
  return [
    props.title
      ? `height: calc(100% - 141px);` + `top: 80px;`
      : `height: calc(100% - 81px);` + `top: 20px;`,
  ];
});
</script>

<style scoped>
.preview-body {
  width: 340px;
  height: 680px;
  position: relative;
}
.preview-body-bg {
  position: absolute;
  height: 100%;
  width: 100%;
  background-size: 100% 100%;
  background-image: url("@/theme/image/phone.png");
  background-repeat: no-repeat;
  z-index: 1;
}
.preview-body-head {
  width: 100%;
  height: 60px;
  position: absolute;
  top: 20px;
  text-align: center;
  border-bottom: 1px solid var(--el-border-color);
}
.preview-body-head-title {
  width: 100%;
  position: absolute;
  bottom: 10px;
}
.preview-body-html {
  position: absolute;
  width: calc(100% - 64px);
  left: 22px;
  padding: 10px;
  word-wrap: break-word;
  overflow-y: scroll;
  z-index: 2;
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 20px;
}
.preview-body-html::-webkit-scrollbar {
  width: 0;
}
</style>